﻿using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;

namespace OcelotService
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args)
        {
            var config = new ConfigurationBuilder()
              .AddCommandLine(args)
              .Build();

            var ip = config["ip"];
            var port = config["port"];

            return WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .UseUrls($"http://{ip}:{port}")
                .ConfigureAppConfiguration((hostingContext, builder) =>
                {
                    //结合Consul
                    builder.AddJsonFile("./Config/ReRoutesUseServiceDiscovery.json", false, true);
                });
        }
    }
}
